using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Sudoku.Utilities
{
	public class OptionData
	{
		public bool Sound;
		public bool SingleSolutionSudoku;

		public OptionData()
		{
			Sound = true;
			SingleSolutionSudoku = true;
		}
	}

	public interface IOptionsServices
	{
		void SaveOptions(OptionData options);
		OptionData LoadOptions();
		void ClearOptionsData();
	}

	public class OptionsServices : IOptionsServices
	{
		Game Game;
		string FileName = "Options.xml";
		FileIOService FileService;

		public OptionsServices(Game game)
		{
			Game = game;
			FileService = (FileIOService)Game.Services.GetService(typeof(FileIOService));
			
			if (!FileService.IsFileAvaible(FileName))
			{
				ClearOptionsData();
			}
		}

		public void ClearOptionsData()
		{
			SaveOptions(new OptionData());
		}

		public void SaveOptions(OptionData options)
		{
			FileService.SaveFile(FileName, options, typeof(OptionData));
		}

		public OptionData LoadOptions()
		{
			OptionData option = FileService.LoadFile(FileName, typeof(OptionData)) as OptionData;
			return option;
		}
	}
}
